package com.sk.cardeal.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.cardeal.R;
import com.sk.cardeal.entity.WorkForm;

import java.util.List;

/**
 * Created by sk on 2018/1/18.
 */

public class WorkFormAdapter extends BaseQuickAdapter<WorkForm, BaseViewHolder> {

    public WorkFormAdapter(int layoutResId, @Nullable List<WorkForm> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WorkForm item) {
        helper.setText(R.id.form_num, "工单号：" + item.getCode())
                .setText(R.id.car_num, item.getCarNumber())
                .setText(R.id.fix_type, item.getRepairName() == null ? "暂无" : item.getRepairName())
                .setText(R.id.in_time, item.getInTime() == null ? "暂无" : item.getInTime());
        switch (item.getState()) {
            case 0:
                helper.setText(R.id.tv_status, "待开单");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.red_color_bg);
                break;
            case 1:
                helper.setText(R.id.tv_status, "待派单");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.blue_color_bg);
                break;
            case 2:
                helper.setText(R.id.tv_status, "维修中");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.green_color_bg);
                break;
            case 3:
                helper.setText(R.id.tv_status, "待检验");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.blue_color_bg);
                break;
            case 4:
                helper.setText(R.id.tv_status, "待结算");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.red_color_bg);
                break;
            case 5:
                helper.setText(R.id.tv_status, "待维修");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.red_color_bg);
                break;
            case 6:
                helper.setText(R.id.tv_status, "作废");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.red_color_bg);
                break;
            case 7:
                helper.setText(R.id.tv_status, "用户已确认");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.blue_color_bg);
                break;
            case 8:
                helper.setText(R.id.tv_status, "草稿");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.grey_color_bg);
                break;
            case 9:
                helper.setText(R.id.tv_status, "工单待确认");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.yellow_color_bg);
                break;
            case 10:
                helper.setText(R.id.tv_status, "合格出厂");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.blue_color_bg);
                break;
            case 11:
                helper.setText(R.id.tv_status,"修改待确认");
                helper.setBackgroundRes(R.id.tv_status,R.drawable.red_color_bg);
                break;
        }
    }

}
